import type { KnowledgePage, KnowledgeParams, DoctorPage, PageParams, Like, DepartmentList, Image, ConsultOrderPreData, ConsultOrderPreParams, PartialConsult } from '@/types/consult'
import { request } from '@/utils/request'

// 首页分类列表
export const getKnowledgePage = (params: KnowledgeParams) =>
    request<KnowledgePage>('/patient/home/knowledge', 'GET', params)

// 关注的医生列表
export const getRecommendDocPage = (params: PageParams) =>
    request<DoctorPage>('/home/page/doc', 'GET', params)

// 关注操作
export const followLike = (data: Like) =>
    request('/like', 'POST', data)

// 获取科室列表
export const getAllDep = () => request<DepartmentList>('/dep/all')

//图片上传
export const uploadImage = (file: File) => {
    const fd = new FormData()
    fd.append('file', file)
    return request<Image>('/upload', 'POST', fd)
}

// 拉取预支付订单信息
export const getConsultOrderPre = (params: ConsultOrderPreParams) =>
  request<ConsultOrderPreData>('/patient/consult/order/pre', 'GET', params)

// 生成订单
export const createConsultOrder = (data: PartialConsult) =>
  request<{ id: string }>('/patient/consult/order', 'POST', data)

  // 获取支付地址  0 是微信  1 支付宝
export const getConsultOrderPayUrl = (params: {
  paymentMethod: 0 | 1
  orderId: string
  payCallback: string
}) => request<{ payUrl: string }>('/patient/consult/pay', 'POST', params)
